Repository navigation
ecs 0.7.0: SIMD lanes at storage precision across rows, filtered rows and large arms - #288
Merged
Merged
Conversation
… rows, filtered rows and large arms - Every compiled kernel's WASM computes at storage precision: F32 arithmetic rounds each step to f32, in lanes and a row at a time alike, a row at a time in f32 instructions; number fields compute in f64, in f64x2 lanes. - Locals assigned once are written into their reads before planning, so nested calls such as Vec3.add(p, Vec3.scale(v, d)) run as whole elements across rows: integrate 0.95 -> 0.27 ns a row. - Across rows: per-row values spread over each element's leaves, per-row locals, kept lanes for partial stores and padding, f64 elements. - Filtered rows run across rows under eight rows' masks of passing ticks: integrate changed half 1.11 -> 0.49 ns, changed all 100K kernels 64.5 -> 26.5 us. - Interleaved arms past the budget are skipped by groups no row takes them, their spans loaded in the arm. - Component modeling rules, and perf.md's measurements behind them. Co-Authored-By: OpenCode <noreply@opencode.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@adobe/ecs0.7.0: compiled kernels run in SIMD lanes in many more cases, at storage precision.Behavior change: every compiled kernel's WASM now computes at storage precision, not only
kernel: trueones. Arithmetic onF32fields rounds each step to f32, in lanes and one row at a time alike, so every row gets the same bits whether or not it falls in a group of 4.numberfields compute in f64. The JS kernel still computes as written. Thekerneldoc indeclaration.ts, guide chapter 14 anddesign.mdare updated.What changed
forward-locals.ts): nested calls such asVec3.add(p, Vec3.scale(v, d))now run as whole elements across rows.changed): run 4 rows at a time under masks from the rows' change ticks. Masks cover 8 rows at once; 8 rows with no change are skipped whole. No branch per row.ifarms over the size budget are skipped in groups of 4 where no row takes them, with the fields only that arm uses loaded inside it, instead of the whole kernel falling back to one row at a time.rules/component.x.ts.md, with a pointer in the architecture standard.perf.mdrecords the measurements behind them.Results (M4 Max, one thread, ns/row unless noted)
integrate(guide pattern, 1M)integrate f64integrate changed half(new)changed all 100K kernels(µs per system)sparse changedmove, WASM without SIMDMoreComplexSystem(1M)The guide's
movewith SIMD runs at 0.227 ns/row, the same as its loads and stores alone, which is one core's memory throughput. Our ecs_benchmark comparison against the C++ libraries otherwise stays within noise: its systems are line-for-line ports that were alreadykernel: true.Tests
Vec3/Vec4/f64 elements, partial stores andifs.forward-locals.test.ts, the new across-rows cases, the comparison-rounding regression, andinterleaved-arms.test.ts.pnpm run buildandpnpm testat the ecs root, plus check:workspace, typecheck, lint, docs and build at both roots, all pass locally.